define(["jquery", "easy-admin", "treetable"], function ($, ea) {
    var table = layui.table,
        treetable = layui.treetable;
    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'mall.fxorder/index',
        edit_url: 'mall.fxorder/edit',
        export_url: 'mall.fxorder/export'
    };
    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                height:'full-50',
                toolbar: ['refresh',
                    [],
                    'export'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id',minwidth: 60,search:false},
                    {field: 'ordersn', title: '订单号', width: 220},
                    {field: 'nickName', title: '下单用户', minwidth: 90,search:false},
                    {field: 'fromnickName', title: '推荐人', minwidth: 90,search:false},
                    {field: 'commission', title: '直推奖励', minwidth: 90,search:false,templet: ea.table.price},
                    {field: 'againprice', title: '复购奖励', minwidth: 90,search:false,templet: ea.table.price},
                    {field: 'payprice', title: '订单金额',search:false,minwidth:90,templet: ea.table.price},
                    {field: 'orderstatus', title: '订单状态',search:'select',minwidth:100,selectList: {"0":"待支付","1":"待发货","2":"待收货","3":"已完成","4":"售后/退款","9":"已取消"}},
                    {field: 'create_time', title: '下单时间', width:170,search: 'range'},
                    {
                        width: 200,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '订单详情',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            }],
                        ]
                    }
                ]],
            });
            ea.listen();
        },
        edit:function (){
            ea.listen();
        }
    }
    return Controller;
});